home *** CD-ROM | disk | FTP | other *** search
/ Freelog 112 / FreelogNo112-NovembreDecembre2012.iso / Jeu / deadlyrace / deadlyrace_setup.exe / {app} / Data / Scripts / lambo_mesh.lua < prev    next >
Encoding:
Text File  |  2010-03-27  |  2.1 KB  |  110 lines

  1. local script = globalObject;
  2.  
  3. local player = nil;
  4.  
  5. local commandMap = {};
  6.  
  7. local mgun, mgun_b, rlauncher, mines = nil, nil, nil, nil;
  8.  
  9.  
  10. local function ExecuteCommands()
  11.     while(SetNextCommand(script))
  12.     do
  13.         local command = GetCurrentCommand(script);
  14.         if (commandMap[command])
  15.         then
  16. --            CheckString(command);
  17.             commandMap[command]();
  18.             
  19.         end
  20.     end
  21. end
  22.  
  23. local function ShowPart(n, show)
  24.     if (n == 1)
  25.     then
  26.         SetObjectVisible(mgun_b, show);
  27.     elseif (n == 2)
  28.     then
  29.         SetObjectVisible(rlauncher, show);
  30.     elseif (n == 3)
  31.     then
  32.         SetObjectVisible(mines, show);
  33.     end    
  34. end
  35.  
  36. local function ShowPart2()
  37.     local n, show = GetCurrentParams(script);
  38.     n = tonumber(n);
  39.     show = tonumber(show);
  40.     local show2 = false;
  41.     if (show == 1)
  42.     then
  43.         show2 = true;
  44.     end
  45.     ShowPart(n, show2);
  46. end
  47.  
  48. local function UpdateParts()
  49.     if (IsWeaponMounted(3, 1))
  50.     then
  51.         ShowPart(1, true);
  52.     end
  53.     if (IsWeaponMounted(3, 2))
  54.     then
  55.         ShowPart(2, true);
  56.     end
  57.     if (IsWeaponMounted(3, 3))
  58.     then
  59.         ShowPart(3, true);
  60.     end
  61. end
  62.  
  63. local function AddObject()
  64.     player = StringToPointer(GetCurrentParams(script));
  65.  
  66. --~     mgun = FindObject(player, "mgun");
  67. --~     SetObjectVisible(mgun, false);
  68.     mgun_b = FindObject(player, "mgun_b");
  69.     SetObjectVisible(mgun_b, false);
  70.     rlauncher = FindObject(player, "rlauncher");
  71.     SetObjectVisible(rlauncher, false);
  72.     mines = FindObject(player, "mines");
  73.     SetObjectVisible(mines, false);
  74.     
  75.     UpdateParts();
  76. end
  77.  
  78. local function DeleteObject()
  79.     Release(player);
  80.     Release(mgun_b);
  81.     Release(rlauncher);
  82.     Release(mines);
  83.     player = nil;
  84.     StopScript(script);
  85. end
  86.  
  87. local function ReleaseAll()
  88.     DeactivateInterface(player);
  89.     player = nil;
  90. end
  91.  
  92. local function SetActive()
  93.     local x, y, z = GetPosition(player);
  94.     SetDirectParameters2(x, y, z);
  95. end
  96.  
  97. commandMap["add_object"] = AddObject;
  98. commandMap["delete_object"] = DeleteObject;
  99. commandMap["release_all"] = ReleaseAll;
  100. commandMap["set_active"] = SetActive;
  101. commandMap["update_parts"] = UpdateParts;
  102. commandMap["show_part"] = ShowPart2;
  103.  
  104. while(true)
  105. do
  106.     ExecuteCommands();
  107.     
  108.     Update();
  109. end
  110.